/**
 * 
 */
package com.zxc.xml;

import java.io.StringReader;
import java.util.List;

import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.Node;
import org.dom4j.XPath;
import org.dom4j.io.SAXReader;

import cn.hutool.core.io.FileUtil;

/**
 * @author ThinkPad
 *
 */
public class Dom4jTest {

	public static void main(String[] args) throws DocumentException {
		String xmlStr = getDemo();
		
		Document doc = loadDocument(xmlStr);
		
		Element AirShoppingRS = doc.getRootElement();
		
		System.out.println(AirShoppingRS.getName());
		
//		Element DocumentElm = AirShoppingRS.element("Document");
//		System.out.println(DocumentElm.asXML());
		
		
		List<Element> elms = AirShoppingRS.elements();
		for (Element element : elms) {
			System.out.println(element.asXML());
		}
	}
	
	
	
	public static Document loadDocument(String xml) throws DocumentException {
		SAXReader saxReader = new SAXReader();
		return saxReader.read(new StringReader(xml));
	}
	
	private static String getDemo() {
		return FileUtil.readUtf8String(Dom4jTest.class.getResource("Dom4jTestXml.xml").getPath());
	}
}
